package com.future.controller;

import com.aliyun.oss.OSSClient;
import com.future.exception.NullException;
import com.future.exception.OneException;
import com.future.pojo.*;
import com.future.service.AdminService;
import com.future.service.MusicService;
import com.future.service.UserService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import javazoom.jl.decoder.Bitstream;
import javazoom.jl.decoder.BitstreamException;
import javazoom.jl.decoder.Header;
import org.apache.log4j.Logger;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.commons.CommonsMultipartFile;

import javax.servlet.http.HttpSession;
import java.io.BufferedInputStream;
import java.io.IOException;
import java.net.URL;
import java.net.URLConnection;
import java.security.SecureRandom;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

@Controller
@RequestMapping("/admin")
public class AdminController {
    static Logger logger = Logger.getLogger(MusicController.class);

    @Autowired
    private AdminService adminService;

    @Autowired
    private UserService userService;

    @Autowired
    private MusicService musicService;


    @ApiOperation(value = "增加用户")
    @PostMapping("/adduser")//测试通过
    @ResponseBody
    public Judge addUser(String userName, String userHao, String userGen, String userPwd, String userEmail) throws NullException {
        //异常处理，不能为空
        if(userName==null || userHao==null || userGen==null || userPwd == null || userEmail==null){
            throw new NullException("新加用户信息不能为空！");
        }
        Judge judge = new Judge();
        //检查用户是否存在
        int nums = userService.checkUserHao(userHao,"普通用户");
        if(nums!=1){
            //添加用户
            int num = adminService.adduser(userName,userPwd,userHao,userEmail,userGen);
            if(num==1){
                judge.setStatusCode(1);
                judge.setInfo("添加成功！");
            }else{
                judge.setStatusCode(-1);
                judge.setInfo("添加失败！");
            }
            return judge;
        }else{
            judge.setStatusCode(0);
            judge.setInfo("用户已存在！");
            return judge;
        }
    }

    @ApiOperation(value = "删除一个用户")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", value = "用户Id", required = true)
    })
    @GetMapping("/deleteUser")                                 //测试通过
    @ResponseBody
    public Judge deleteUser(Integer userId) throws NullException {
        if(userId==null){
            throw new NullException("用户ID不能为空");
        }
        //删除用户
        int result = adminService.deleteUser(userId);
        Judge judge = new Judge();
        if (result == 1) {
            judge.setInfo("删除成功！");
            judge.setStatusCode(1);
        } else {
            judge.setInfo("删除失败！");
            judge.setStatusCode(0);
        }
        return judge;
    }

    @ApiOperation(value = "批量删除用户")
    @GetMapping("/BatchdeleteUsers")
    @ResponseBody
    public Judge BatchdeleteUsers(@RequestParam(value = "numbers", required = false)List<String> numbers) throws NullException {
        Judge judge = new Judge();
        System.out.println(numbers.size());
        System.out.println(numbers);
        //异常处理
        if(numbers==null){
            throw new NullException("参数不能为空！");
        }else if(numbers.size()==1){
            //处理传送数据
            String first = numbers.get(0).replace("[","");
            String last = first.replace("]","");
            numbers.remove(0);
            numbers.add(0,last);
            System.out.println(numbers.get(0));
            //动态sql批量删除
            int num  = adminService.BatchdeleteUsers(numbers);
            if(num==1){
                judge.setStatusCode(1);
                judge.setInfo("删除成功！");
                return judge;
            }else{
                judge.setStatusCode(-1);
                judge.setInfo("删除失败！");
                return judge;
            }
        }else{
            //处理数据
            String first =  numbers.get(0).replace("[","");
            numbers.remove(0);
            numbers.add(0,first);
            String last = numbers.get(numbers.size()-1).replace("]","");
            numbers.remove(numbers.size()-1);
            numbers.add(numbers.size()-1,last);
            //动态sql处理数据
            int num  = adminService.BatchdeleteUsers(numbers);
            if(num==1){
                judge.setStatusCode(1);
            }else{
                judge.setStatusCode(-1);
            }
            return judge;
        }

    }

    @ApiOperation(value = "管理员更新用户信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", value = "用户Id", required = true),
            @ApiImplicitParam(name = "userBirth", value = "用户生日", required = true),
            @ApiImplicitParam(name = "userName", value = "用户名字", required = true),
            @ApiImplicitParam(name = "userEmail", value = "用户邮箱", required = true),
            @ApiImplicitParam(name = "userGen", value = "用户性别", required = true),
            @ApiImplicitParam(name = "userThing", value = "用户事情", required = true),
            @ApiImplicitParam(name = "userImgload", value = "用户头像", required = true),
            @ApiImplicitParam(name = "userLv", value = "用户等级", required = true),
            @ApiImplicitParam(name = "userVipBal", value = "用户VIP时间", required = true)
    })
    @GetMapping("/updateUser")                                //测试还未成功
    @ResponseBody
    public Judge updateUser(Integer userId, String userName, String userEmail, String userLv, Integer userVipBal,String userGen) throws NullException {
        System.out.println(userId);
        if(userId==null){
            throw new NullException("用户ID不能为空！");
        }
        //执行修改语句
        int result = adminService.updateUser(userId,userName,userEmail,userLv,userVipBal,userGen);
        System.out.println(result);
        Judge judge = new Judge();
        if (result == 1) {
            judge.setInfo("修改成功！");
            judge.setStatusCode(1);
        } else {
            judge.setInfo("修改失败！");
            judge.setStatusCode(0);
        }
        return judge;
    }

    @ApiOperation(value = "按照名字模糊查询用户")
    @GetMapping("/queryUserByusername")                        //测试通过
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userName", value = "用户姓名", required = true)
    })
    @ResponseBody
    public List queryUserByusername(String userName) {
        System.out.println(userName);
        //首次进入页面page为null，将page赋值为1
        List<Users> list = adminService.queryUserByusername(userName);

        return list;
    }

    @ApiOperation(value = "查询全部用户")
    @GetMapping("/queryAllUsers")        //测试通过
    public String queryAllUsers(Model model,Integer page) {
        //首次进入页面page为null，将page赋值为1
        if(page==null){
            page=1;
        }
        //得到总数据条数
        int count = adminService.userCount();
        int sumPage;
        //计算出总页数
        if (count % 10 != 0) {
            sumPage=count/10+1;
        }else {
            sumPage = count / 10;
        }
        //查询一页所需数据
        List<Users> list = adminService.queryAllUsers((page)*10-10,10);
        model.addAttribute("page",page);
        model.addAttribute("sumPage",sumPage);
        model.addAttribute("Users", list);
        return "/ypb/Y-background/Y-user/user.html";
    }
//----------👆管理员对用户操作---------👇管理员对歌手操作-------
    @ApiOperation(value = "增加歌手")
    @PostMapping("/addSinger")
    public Judge addSinger(String userName,String userGen,String userHao,String userPwd,String userEmail,String userBirth,String userHot,String userImgload,String userThing){
        Judge judge = new Judge();
        //判断歌手是否已经存在
        int nums = userService.checkUserHao(userHao,"歌手");
        if(nums!=1){
            String userLv = "歌手";
            //执行添加sql语句
            int num = adminService.addSinger(userName,userGen,userPwd,userHao,userEmail,userBirth,userHot,userImgload,userThing,userLv);
            if(num==1){
                judge.setStatusCode(1);
                judge.setInfo("添加成功！");
            }else{
                judge.setStatusCode(-1);
                judge.setInfo("添加失败！");
            }
            return judge;
        }else{
            judge.setStatusCode(0);
            judge.setInfo("歌手已存在！");
            return judge;
        }
    }

    @ApiOperation(value = "查询全部歌手")
    @GetMapping("/querySinger")                                 //测试通过
    public String querySinger(Model model,Integer page) {
        //首次进入页面page为null，将page赋值为1
        if(page==null){
            page=1;
        }
        //得到歌手总个数
        int count = adminService.singerCount();
        //计算出总页数
        int sumPage = 0;
        if (count % 10 != 0) {
            sumPage=count/10+1;
        }else{
            sumPage=count/10;
        }
        //得到一页所需的条数据
        List<Users> list = adminService.querySinger(page*10-10,10);
        model.addAttribute("page",page);
        model.addAttribute("sumPage",sumPage);
        model.addAttribute("Users", list);
        return "/ypb/Y-background/Y-music/singer.html";

    }


    @ApiOperation(value = "按名字模糊查询一个歌手")
    @GetMapping("/querySingerByusername")                      //测试通过
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userName", value = "用户姓名", required = true)
    })
    @ResponseBody
    public List querySingerByusername(String userName) {
        List<Users> list = adminService.querySingerByusername(userName);
        return list;
    }


    @ApiOperation(value = "管理员更新歌手信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", value = "用户Id", required = true),
            @ApiImplicitParam(name = "userBirth", value = "用户生日", required = true),
            @ApiImplicitParam(name = "userName", value = "用户名字", required = true),
            @ApiImplicitParam(name = "userEmail", value = "用户邮箱", required = true),
            @ApiImplicitParam(name = "userGen", value = "用户性别", required = true),
            @ApiImplicitParam(name = "userThing", value = "用户事情", required = true),
            @ApiImplicitParam(name = "userImgload", value = "用户头像", required = true),
            @ApiImplicitParam(name = "userLv", value = "用户等级", required = true),
            @ApiImplicitParam(name = "userVipBal", value = "用户VIP时间", required = true)
    })
    @GetMapping("/updateSinger")                                //测试还未成功
    @ResponseBody
    public Judge updateSinger(Integer userId,String userName, String userGen, String userPwd,String userBirth, String userHot, String userImgload,String userThing) {
        //执行修改语句
        int result = adminService.updateSinger(userId,userName,userGen,userPwd,userBirth,userHot,userImgload,userThing);
        Judge judge = new Judge();
        if (result == 1) {
            judge.setInfo("修改成功！");
            judge.setStatusCode(1);
        } else {
            judge.setInfo("修改失败！");
            judge.setStatusCode(0);
        }
        return judge;
    }



//----------👆管理员对歌手操作---------👇管理员对音乐操作-------


    @ApiOperation(value = "查询音乐")
    @GetMapping("/allMusic")                             //测试通过
    public String allMusic(Model model,Integer page) {
        //第一次进入页面page为null，将page赋值为1
        if(page==null){
            page=1;
        }
        //得到数据总数，算出总页数
        int count = adminService.musicCount();
        int sumPage = 0;
        if (count % 10 != 0) {
            sumPage=count/10+1;
        }else{
            sumPage=count/10;
        }
        //得到第几页的数据并返回list
        List<Musics> list = adminService.queryAllMusic(page*10-10,10);
        model.addAttribute("page",page);
        model.addAttribute("sumPage",sumPage);
        model.addAttribute("Musics", list);
        return "/ypb/Y-background/Y-music/music2.html";
    }


    @ApiOperation(value = "按名字模糊查询一首歌曲")
    @GetMapping("/querySongBymcName")                      //测试通过
    @ApiImplicitParams({
            @ApiImplicitParam(name = "mcName", value = "歌曲名", required = true)
    })
    @ResponseBody
    public List querySongByusername(String mcName) {
        List<Musics> list = adminService.querySongBymcName(mcName);
        return list;
    }



    @ApiOperation(value = "增加音乐")
    @RequestMapping("/addSong")
    @ResponseBody
    public Judge addSong(@RequestParam(value="file",required = false) CommonsMultipartFile filex,String mcName, Integer mcHot, Integer mcLv,  String mcMvLoad, String albName, String userName, String mcLrc, Integer albId) {
        Judge judge = new Judge();
        String mcLoad = null;
        String mcTime = null;
        String mcLoaddele  = null;
        //检查歌曲是否已经存在
        int nums = adminService.checkSong(mcName, userName);
        System.out.println(nums);
            if (nums != 1) {
                SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
                String endpoint = "http://oss-cn-hangzhou.aliyuncs.com";
                String accessKeyId = "LTAI5tMD2SS1nzgLxYwxggVJ";
                String accessKeySecret = "ujQ3Ls8rcvEnLB9WNzVv75DryEdBhT";
                //得到文件原始名字
                String uploadFileName = filex.getOriginalFilename();
                System.out.println(uploadFileName);
                int miao = 0;
                //获取文件路径
                String fileName = uploadFileName;
                String bucketName = "jianglin-bucket";
                // 获取文件的后缀名
                String suffixName = fileName.substring(fileName.lastIndexOf("."));
                System.out.println(suffixName);

                // 生成上传文件名
                String finalFileName = System.currentTimeMillis() + "" + new SecureRandom().nextInt(0x0400) + suffixName;
                String objectName = sdf.format(new Date()) + "/" + finalFileName;
                OSSClient ossClient = new OSSClient(endpoint, accessKeyId, accessKeySecret);
                try {
                    ossClient.putObject(bucketName, objectName, filex.getInputStream());
                } catch (IOException e) {
                    e.printStackTrace();
                }

                // 设置URL过期时间。
                Date expiration = new Date(System.currentTimeMillis() + 999999999 * 1000000000);
                // 生成以GET方法访问的签名URL，访客可以直接通过浏览器访问相关内容。
                URL url = ossClient.generatePresignedUrl(bucketName, objectName, expiration);
                ossClient.shutdown();
                //获取mp3文件时间
                try {
                    URL urlfile = new URL(url.toString());
                    URLConnection con = urlfile.openConnection();
                    int b = con.getContentLength();// 得到音乐文件的总长度
                    BufferedInputStream bis = new BufferedInputStream(con.getInputStream());
                    Bitstream bt = new Bitstream(bis);
                    Header h = bt.readFrame();
                    int time = (int) h.total_ms(b);
                    miao = time / 1000;
                } catch (IOException e) {
                    e.printStackTrace();
                } catch (BitstreamException e) {
                    e.printStackTrace();
                }
                int mm = (miao % 3600) / 60;
                int ss = (miao % 3600) % 60;
                System.out.println((mm < 10 ? ("0" + mm) : mm) + ":" + (ss < 10 ? ("0" + ss) : ss));
                mcLoad = url.toString();
                mcTime = (mm < 10 ? ("0" + mm) : mm) + ":" + (ss < 10 ? ("0" + ss) : ss);
                mcLoaddele = objectName;
                System.out.println(url.toString());
                //执行添加语句
                int result = adminService.addSong(mcName,mcHot,mcLv,mcMvLoad,mcLoad,mcTime,albName,userName,mcLrc,albId,mcLoaddele);
                System.out.println("result"+result);
                if (result == 1) {
                    judge.setStatusCode(1);
                    judge.setInfo("添加成功！");
                    return judge;
                } else {
                    judge.setStatusCode(-1);
                    judge.setInfo("添加失败！");
                    return judge;
                }
            } else {
                judge.setStatusCode(0);
                judge.setInfo("歌曲已存在！");
                return judge;
            }
        }

    @ApiOperation(value = "删除歌曲")
    @PostMapping("/deleteSong")                            //  同时删除oss完成和数据库
    @ResponseBody
    public Judge deleteMusic(Integer mcId) throws NullException {
        //异常处理，不为空
        if(mcId == null){
            throw new NullException("音乐ID不能为空！");
        }else {
            Judge judge = new Judge();
            //数据库和oss同时删除音乐
            Albmusic albmusic = musicService.queryByIdAlbmusic(mcId);
            String load = albmusic.getMcLoaddele();
            String endpoint = "http://oss-cn-hangzhou.aliyuncs.com";
            String accessKeyId = "LTAI5tMD2SS1nzgLxYwxggVJ";
            String accessKeySecret = "ujQ3Ls8rcvEnLB9WNzVv75DryEdBhT";
            //获取文件路径
            String filePath = load;
            String bucketName = "jianglin-bucket";
            OSSClient ossClient = new OSSClient(endpoint, accessKeyId, accessKeySecret);
            boolean exist = ossClient.doesObjectExist(bucketName, filePath);
            ossClient.deleteObject(bucketName, filePath);
            ossClient.shutdown();

            int result = musicService.deleteMusic(mcId);

            if (exist && result > 0) {
                judge.setInfo("删除成功！！");
                judge.setStatusCode(1);
            } else {
                judge.setInfo("删除失败！");
                judge.setStatusCode(-1);
            }

            return judge;
        }
    }


    @ApiOperation(value = "管理员更新音乐信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", value = "用户Id", required = true),
            @ApiImplicitParam(name = "userBirth", value = "用户生日", required = true),
            @ApiImplicitParam(name = "userName", value = "用户名字", required = true),
            @ApiImplicitParam(name = "userEmail", value = "用户邮箱", required = true),
            @ApiImplicitParam(name = "userGen", value = "用户性别", required = true),
            @ApiImplicitParam(name = "userThing", value = "用户事情", required = true),
            @ApiImplicitParam(name = "userImgload", value = "用户头像", required = true),
            @ApiImplicitParam(name = "userLv", value = "用户等级", required = true),
            @ApiImplicitParam(name = "userVipBal", value = "用户VIP时间", required = true)
    })
    @GetMapping("/updateSong")                                //测试还未成功
    @ResponseBody
    public Judge updateSong(Integer mcId,String mcName, int mcHot, int mcLv, String albName, String userName, String mcLrc, int albId) {
        //执行修改语句
        int result = adminService.updateSong(mcId,mcName,mcHot,mcLv,albName,userName,mcLrc,albId);
        Judge judge = new Judge();
        if (result == 1) {
            judge.setInfo("修改成功！");
            judge.setStatusCode(1);
            return judge;
        } else {
            judge.setInfo("修改失败！");
            judge.setStatusCode(0);
            return judge;
        }
    }

    @ApiOperation(value = "批量删除音乐")
    @GetMapping("/BatchdeleteSong")
    @ResponseBody
    public Judge BatchdeleteSong(@RequestParam(value = "numbers", required = false)List<String> numbers) throws NullException {
        System.out.println(111);
        Judge judge = new Judge();
        if(numbers==null){
            throw new NullException("参数不能为空！");
        }
        else if(numbers.size()==1){
            String first = numbers.get(0).replace("[","");
            String next = first.replace("]","");
            String last = next.replace("\"","");
            numbers.remove(0);
            numbers.add(0,last);
            System.out.println(numbers.get(0));
            //根据名字删除
            int num  = adminService.BatchdeleteSongs(numbers);
            if(num==1){
                judge.setStatusCode(1);
                return judge;
            }else{
                judge.setStatusCode(-1);
                return judge;
            }
        }else{
            String first =  numbers.get(0).replace("[\"","");
            numbers.remove(0);
            numbers.add(0,first);
            String last = numbers.get(numbers.size()-1).replace("\"]","");
            numbers.remove(numbers.size()-1);
            numbers.add(numbers.size()-1,last);
            int num  = adminService.BatchdeleteUsers(numbers);
            if(num==1){
                judge.setStatusCode(1);
                judge.setInfo("删除成功!");
                return judge;
            }else{
                judge.setStatusCode(-1);
                judge.setInfo("删除失败!");
                return judge;
            }
        }
    }

//    -----------👆音乐------专辑-------

    //删除专辑
    @ApiOperation(value = "删除一个专辑")
    @GetMapping("/deleteAlbum")                                 //测试通过
    @ResponseBody
    @Transactional
    public Judge deleteAlbum(Integer albId) throws OneException {
        if(albId==null){
            throw new NullException("专辑ID为空不被允许！");
        }else{
            //删除专辑同时也删除专辑中的音乐
            int result = adminService.deletesong(albId);
            int num = adminService.deleteAlbum(albId);
            if(result !=1 || num != 1){
                throw new RuntimeException();
            }
            if (result == 1 && num==1) {
                Judge judge = new Judge();
                judge.setInfo("");
                judge.setStatusCode(1);
                return judge;
            } else {
                Judge judge = new Judge();
                judge.setInfo("删除失败！");
                judge.setStatusCode(0);
                return judge;
            }
        }
    }

    @ApiOperation(value = "查询专辑")
    @GetMapping("/queryAllAlbum")                             //测试通过
    public String allAlbum(Model model,Integer page) {
        //第一次进入页面page为null，将page赋值为1
        if(page==null){
            page=1;
        }
        //得到数据总数，算出总页数
        int count = adminService.albumCount();
        int sumPage = 0;
        if (count % 10 != 0) {
            sumPage=count/10+1;
        }else{
            sumPage=count/10;
        }
        //得到第几页的数据并返回list
        List<Album> list = adminService.queryAllAlbum(page*10-10,10);
        model.addAttribute("page",page);
        model.addAttribute("sumPage",sumPage);
        model.addAttribute("Album", list);
        return "/ypb/Y-background/Y-music/album.html";
    }



    @ApiOperation(value = "按名字模糊查询一个专辑")
    @GetMapping("/queryAlbumByusername")                      //测试通过
    @ApiImplicitParams({
            @ApiImplicitParam(name = "albName", value = "专辑名称", required = true)
    })
    @ResponseBody
    public List queryAlbumByusername(String albName) throws NullException {
        if(albName==null){
            throw new NullException("抱歉什么也没查到！");
        }
        List<Album> list = adminService.queryalbumByusername(albName);
        return list;
    }


    @ApiOperation(value = "增加专辑")
    @PostMapping("/addAlbum")
    @ResponseBody
    public Judge addAlbum(String albName,String albThing,int userId,int albHot,String albImgload,String albTime,String albLanguage,String albType){
        Judge judge = new Judge();
        //查询专辑是否存在
        int nums = adminService.checkAlbum(albName);
        if(nums!=1){
            //执行添加语句
            int num = adminService.addAlbum(albName,albThing,userId,albHot,albImgload,albTime,albLanguage,albType);
            if(num==1){
                judge.setStatusCode(1);
                judge.setInfo("添加成功！");
                return judge;
            }else{
                judge.setStatusCode(-1);
                judge.setInfo("添加失败！");
                return judge;
            }
        }else{
            judge.setStatusCode(0);
            judge.setInfo("专辑已存在！");
            return judge;
        }
    }

    @ApiOperation(value = "管理员更新音乐信息")
    @GetMapping("/updateAlbum")                                //测试还未成功
    @ResponseBody
    public Judge updateAlbum(String albName,String albThing,int albHot,String albImgload,String albTime,String albLanguage,String albType,int albId) {

        int result = adminService.updateAlbum(albName,albThing,albHot,albImgload,albTime,albLanguage,albId,albType);
        Judge judge = new Judge();
        if (result == 1) {
            judge.setInfo("修改成功！");
            judge.setStatusCode(1);
            return judge;
        } else {
            judge.setInfo("修改失败！");
            judge.setStatusCode(0);
            return judge;
        }
    }
    @ApiOperation(value = "批量删除专辑")
    @GetMapping("/BatchdeleteAblum")
    @ResponseBody
    public Judge BatchdeleteAblum(@RequestParam(value = "numbers", required = false)List<String> numbers) throws NullException {
        Judge judge = new Judge();
        if(numbers==null){
            throw new NullException("参数不能为空！");
        }
        else if(numbers.size()==1){
            String first = numbers.get(0).replace("[","");
            String next = first.replace("]","");
            String last = next.replace("\"","");
            numbers.remove(0);
            numbers.add(0,last);
            System.out.println(numbers.get(0));
            //根据名字删除
            int num  = adminService.BatchdeleteSongs(numbers);
            if(num==1){
                judge.setStatusCode(1);
                return judge;
            }else{
                judge.setStatusCode(-1);
                return judge;
            }
        }else{
            String first =  numbers.get(0).replace("[\"","");
            numbers.remove(0);
            numbers.add(0,first);
            String last = numbers.get(numbers.size()-1).replace("\"]","");
            numbers.remove(numbers.size()-1);
            numbers.add(numbers.size()-1,last);
            int num  = adminService.BatchdeleteUsers(numbers);
            if(num==1){
                judge.setStatusCode(1);
                judge.setInfo("删除成功!");
                return judge;
            }else{
                judge.setStatusCode(-1);
                judge.setInfo("删除失败!");
                return judge;
            }
        }

    }

    @RequestMapping("/out")
    @ResponseBody
    public Judge signout(HttpSession session){
        Judge judge = new Judge();
        judge.setInfo("/loginpage");
        judge.setStatusCode(1);
        session.invalidate();
        return judge;
    }

    @ApiOperation(value = "查询所有评论")
    @GetMapping("/queryDis")                               //测试通过
    public String queryDis(Model model,Integer page) {
        if(page==null){
            page=1;
        }
        int count = 5;
        int sumPage = 1;
        List<Discuss> list = adminService.queryDis();
        model.addAttribute("page",page);
        model.addAttribute("sumPage",sumPage);
        model.addAttribute("Musics", list);
        return "/ypb/Y-background/Y-music/comment.html";
    }
}
